<!--公共组件-->
<template lang="pug">
  el-container
    el-header.jn-red(height="80px")
      div.header-left
        nuxt-link(to="/")
          img.site-logo(src="~assets/images/logo.png")
        h3.site-name 店管家农资营销管理系统
      div.header-right
        a.help(title="点击帮助")
          img(src="~assets/images/help.png")
        el-popover(placement="bottom", width="150", v-model="userVisible")
          ul.user-popover
            li(v-on:click="dialogFormVisiblePassWord = true")
              a 修改密码
            li(v-on:click="dialogFormVisiblePhoneNum = true")
              a 修改手机号
            li
              a 安全退出
          div.user-info(slot="reference", :class="{ active: userVisible }")
            img(src="~assets/images/user-header-img.png")
            div.user-name
              a 上海永通生态工程股份有限公司
              a 15848756851
    el-container
      el-aside(width="180px")
        el-col.el-menu-list(:span="24")
          el-menu.el-menu-vertical(
          default-active="/",
          v-on:open="handleOpen",
          v-on:close="handleClose",
          background-color="#211515",
          text-color="#fff",
          active-text-color="#e52a33"
          width="180px"
          :router="true"
          )
            el-menu-item(index="/")
              i.iconfont.icon-yemian-copy
              span(slot="title") 首页
            el-submenu(index="2")
              template(slot="title")
                i.iconfont.icon-hongbao
                span 营销红包
              el-menu-item-group
                el-menu-item(index="redEnvelopeCreate") 创建红包
                el-menu-item(index="redEnvelopeList") 红包列表
                el-menu-item(index="redEnvelopeQRLib") 二维码库
                el-menu-item(index="redEnvelopeStatistics") 统计报表
            el-menu-item(index="fundAccount")
              i.iconfont.icon-zijin
              span(slot="title") 资金账户
            el-menu-item(index="authenticate")
              i.iconfont.icon-shezhi
              span(slot="title") 企业认证
            el-menu-item(index="userSystem")
              i.iconfont.icon-users
              span(slot="title") 账号管理
      el-main
        nuxt

    el-dialog.dialog-redAdmin.dialog-changePassWord(title="修改密码", :visible.sync="dialogFormVisiblePassWord", width="560px")
      el-form(:model="formChangePW")
        el-form-item(label="原始密码" label-width="20%")
          el-input(v-model="formChangePW.oldPW" placeholder="请输入原始密码")
        el-form-item(label="设置新密码" label-width="20%")
          el-input(v-model="formChangePW.newPW1" placeholder="设置6-16位字符密码")
        el-form-item(label="确认新密码" label-width="20%")
          el-input(v-model="formChangePW.newPW2" placeholder="再次输入新密码")
      .dialog-footer(slot="footer")
        el-button(type="primary", v-on:click="dialogFormVisiblePassWord = false") 保 存
        el-button(v-on:click="dialogFormVisiblePassWord = false") 取 消

    el-dialog.dialog-redAdmin.dialog-changePhoneNum(title="修改手机号", :visible.sync="dialogFormVisiblePhoneNum", width="560px")
      el-form(:model="formChangePW")
        el-form-item(label="新手机号" label-width="20%")
          el-input(v-model="formChangePW.oldPW" placeholder="请输入新手机号")
        el-form-item(label="短信验证码" label-width="20%")
          el-input.sms-input(v-model="formChangePW.newPW1" placeholder="请输入短信验证码")
          el-button.sms-button(v-on:click="getSMSCode", v-show="show") 短信验证码
          el-button.sms-button(disabled="disabled", v-show="!show") {{count}} s

      .dialog-footer(slot="footer")
        el-button(type="primary", v-on:click="dialogFormVisiblePhoneNum = false") 保 存
        el-button(v-on:click="dialogFormVisiblePhoneNum = false") 取 消

</template>

<script>
  export default {
    components: {

    },
    data() {
      return {
        userVisible: false,
        isActive: true,
        dialogFormVisiblePassWord: false,
        dialogFormVisiblePhoneNum: false,
        formChangePW: {
          oldPW: '',
          newPW1: '',
          newPW2: '',
        },
        show: true,
        count: '',
        timer: null,
      }
    },
    beforeCreate: function () {

    },
    create: function () {

    },
    beforeMount: function () {

    },
    mounted: function () {
      // 将侧边栏导航高度设置100%
      const orderHeight = document.documentElement.clientHeight - 80;
      document.querySelector('.el-menu-list').style.height = orderHeight + 'px';
    },
    beforeUpdate: function () {

    },
    updated: function () {

    },
    beforeDestroy: function () {

    },
    destroyed: function () {

    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      getSMSCode: function () {
        const TIME_COUNT = 60;
        if (!this.timer) {
          this.count = TIME_COUNT;
          this.show = false;
          this.timer = setInterval(() => {
            if (this.count > 0 && this.count <= TIME_COUNT) {
              this.count--;
            } else {
              this.show = true;
              clearInterval(this.timer);
              this.timer = null;
            }
          }, 1000)
        }
      }
    },

  }
</script>

<style scoped lang="scss">
  .el-container {
    .el-header {
      background-color: $main-style-red;
      -webkit-transition: width .28s;
      bottom: 0;
      font-size: 0;
      left: 0;
      overflow: hidden;
      position: fixed;
      top: 0;
      transition: width .28s;
      width: 100%;
      z-index: 1;
      .header-left {
        float: left;
        height: 100%;
        display: flex;
        align-items: center;
        .site-logo {
          align-items: center;
        }
        .site-name {
          color: #fff;
          font-size: 30px;
          font-weight: 500;
          margin: 0 0 0 20px;
        }
      }
      .header-right {
        float: right;
        height: 100%;
        display: flex;
        align-items: center;
        overflow: hidden;
        .help {
          position: relative;
          left: 30px;
          cursor: pointer;
        }
        .user-info {
          position: relative;
          left: 90px;
          padding: 20px;
          cursor: pointer;
          outline-color: transparent;
          &.active {
            background-color: #a01d24;
          }
          img {
            width: 68px;
            border-radius: 50%;
            float: left;
          }
          .user-name {
            display: flex;
            flex-wrap: wrap;
            height: 73px;
            position: relative;
            left: 10px;
            a {
              width: 100%;
              font-size: 18px;
              color: #fff;
              line-height: 2;
            }
          }
        }
      }
    }
    .el-aside {
      -webkit-transition: width .28s;
      bottom: 0;
      font-size: 0;
      left: 0;
      overflow: hidden;
      position: fixed;
      top: 80px;
      transition: width .28s;
      z-index: 1;
      .el-menu {
        border-right-width: 0;
        height: 100%;
        .el-menu-item *,
        .el-submenu__title *{
          font-size: 18px;
          font-weight: 600;
        }
      }
      .el-submenu .el-menu-item {
        width: 180px;
        min-width: 180px;
        font-size: 18px;
        font-weight: 600;
      }
      i.iconfont {
        vertical-align: middle;
        margin-right: 5px;
        width: 24px;
        text-align: center;
        font-size: 18px;
        speak: none;
        font-style: normal;
        font-weight: 400;
        font-variant: normal;
        text-transform: none;
        line-height: 1;
        display: inline-block;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }
    }
    .el-main {
      background-color: #fff;
      margin-top: 80px;
      margin-left: 180px;
    }
  }
  .el-popover {
    ul.user-popover {
      list-style: none;
      padding: 0;
      margin: 0;
      li {
        position: relative;
        text-align: center;
        padding: 10px 0;
        cursor: pointer;
        &:after {
          position: absolute;
          right: 0;
          bottom: 0;
          left: 0;
          height: 1px;
          content: '';
          -webkit-transform: scaleY(.5);
          transform: scaleY(.5);
          background-color: #c8c7cc;
        }
        &:last-child:after {
          background-color: #fff;
        }
        a {
          font-size: 14px;
        }
      }
    }
  }

  .dialog-changePhoneNum {
    .sms-input {
      width: 70%;
    }
    .sms-button {
      margin-left: 2%;
    }
  }
</style>
